<!DOCTYPE html>
<meta charset="UTF-8">
<script type="text/javascript">
$(function(){
	$("#tabel1").jqGrid({
	 	url	:'../lesseeadmin/list',
	 	editurl:'../lesseeadmin/edit', 
		caption	: '租户管理员列表',
		//显示数据数
		viewrecords : true,
		altRows : true,
		autowidth: true,
		width : 1000,
		height : 'auto',
		datatype : 'json',
		mtype : 'post',
		rowNum : 10,
		rowList : [3,5,15,25,50],
		prmNames : { search : 'search'},
		sortname : 'id',
		viewrecords : true,
		pager : '#div1',
		jsonReader : {
			repeatitems : false,
			id : 'id'
		},
		colModel : [
			{
				name:'name',
				label:'姓名',
				index:'name',
				align:'center',
				width:100,
				sorttype:'text',
				editable:true,
				editrules : {
					edithidden : true,
					required:true
					}
			},
			{
				name:'username',
				label:'用户名',
				index:'username',
				align:'center',
				width:100,
				sorttype:'text',
				editable:true,
				editrules : {
					edithidden : true,
					required:true,
					email:true
				}	
			},
			{
				name:'phone',
				label:'联系电话',
				index:'phone',
				align:'center',
				width:100,
				sorttype:'text',
				editable:true,
				editrules : {
					edithidden : true,
					required:true
					}	
			},
			{label:'操作',name:'id',index:'id',align:'center',width:50,edittype:"button",formatter:cmgStateFormat,search:false}
		] 
	});

	
	$("#tabel1").jqGrid('navGrid', '#div1', {
			edit : true,
			add : true,
			del : false
			/* //隐藏搜索框
			search:false */
			/* view:true */ //视图
		},{
			//改
			top:200,
			left:600
		},{
			//增
			top:200,
			left:600
		},{
			//删
			top:200,
			left:600
		},{
			//查
			top:200,
			left:600,
			sopt: ['eq', 'ne', 'lt', 'le', 'gt', 'ge', 'bw', 'bn', 'in', 'ni', 'ew', 'en', 'cn', 'nc'],
			multipleSearch:true
		});
	});
	
function cmgStateFormat(cellValue) {
	return "<button class='btn btn-info	 ' onclick=\"change("
			+ cellValue + ")\">重置密码</button>";
}

function change(id) {
	if (confirm('确定要重置密码？')) {
		$.ajaxSettings.async = false;
		$.post("lesseeadmin/changepwd?id=" + id, function(r) {	
				alert(r)		
		});
		$.ajaxSettings.async = true;
	}
}

var checkno = function(val, username){
	if(!/^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$/.test(val)){
		return [false,"请输入正确的邮箱！"];
	}else{
		 return [true,""];
	}
}
</script>
	<table id="tabel1"></table>
	<div id="div1"></div>